// 存放共享状态的
const state = {
    userInfo: { name: "郝许超" },
    num: 1
};
// 计算属性,可以对state中的共享的数据进行提前的处理
const getters = {
    newUserInfo(state) {
        return state.userInfo.name + "好帅";
    }
};
// 以同步的方式修改共享状态:唯一的可以显式的修改共享状态的地方
const mutations = {
    saveVal(state, params) {
        console.log("mutationsparams", params);

        state.userInfo = params;
        localStorage.setItem("userInfo", params);
        state.num = 20;
    }
};
// 允许有异步的操作.通过commit 触发mutations里面的方法.进而修改state状态
const actions = {
    saveValue({ dispatch, commit }, params) {
        console.log("params", params);
        commit("saveVal", params);
        // dispatch("car/saveValueCar", params, { root: true });
    },
    saveValue2() {
        console.log("被触发");
    }
};
export default {
    namespaced: true,
    state,
    getters,
    mutations,
    actions
};
